/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package canteen.sys;

import canteen.sys.model.entity.LoginMaster;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

/**
 *
 * @author TNT
 */
public class SessionFactoryClass {

    private SessionFactory sessionFactory;
    private LoginMaster user;

    public LoginMaster getUser() {
        return user;
    }

    public void setUser(LoginMaster user) {
        this.user = user;
    }

    public SessionFactory getSessionFactory() {
        return sessionFactory;
    }

    private SessionFactoryClass() {

        SessionFactory sf = new AnnotationConfiguration()
                .configure("/canteen/sys/config/hibernate.cfg.xml")
                .buildSessionFactory();
        this.sessionFactory = sf;
    }

    public static SessionFactoryClass getInstance() {
        return SessionFactoryClassHolder.INSTANCE;
    }

    private static class SessionFactoryClassHolder {

        private static final SessionFactoryClass INSTANCE = new SessionFactoryClass();
    }
}
